<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page language="java" import="com.pro.bean.*"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>修改用户信息</title>
    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>css/bootstrap.css">
	<script type="text/javascript" src="<%=basePath%>js/bootstrap.js"></script>
	<script type="text/javascript">
		function check()
		{
			if(document.fuser.username.value=="")
    		{
  				alert("用户名不能为空！");
    			document.fuser.username.focus();
   		 		return false;
    		}
    		if(document.fuser.email.value=="")
    		{
     			alert("邮箱不能为空！");
    			document.fuser.email.focus();
    			return false;
    		}
    		else 
    			if(document.fuser.email.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/i)==-1)
    			{
     				alert("邮箱格式错误!"); 
     				document.fuser.email.focus();
     				return false;
    			}
		}
	</script>

  </head>
  <%
		List list=(List)session.getAttribute("list");
		Iterator it=list.iterator(); 
		System.out.println(list.size());
		%>
  <body>
    <div style="width:400px;margin:auto;overflow:auto;float:middle" class="table-responsive">
    	
    		<form name="fuser" action="<%=basePath%>servlet/EditUserInfoServlet" method="post" onsubmit="return check()">
    		<table width="200px" border="0" class="table table-bordered table-hover">
    			<caption><h3>用户信息</h3></caption>
    			<%
    			//System.out.println("admin_userinfr_e"+(String)session.getAttribute("userid"));
    			int userid=Integer.parseInt((String)session.getAttribute("userid"));
    			//System.out.println("admin_userinfr_e"+userid);
    			String username=(String)session.getAttribute("username");
		System.out.println("EditUserServlet"+username);
    			String password =(String)session.getAttribute("password"); 
    			String company	=(String)session.getAttribute("company");
    			System.out.println("admin_userinfr_e"+company);
    			String email	=(String)session.getAttribute("email");
    			System.out.println("EditUserServlet"+email);
    			 %>
    					<input name="userid" type="hidden"  value="<%=userid %>"></input>
    					<input name="userpwd" type="hidden"  value="<%=password %>"></input>
    			 <tr>
    				<td class="success" width="30%">用户姓名</td>
    				<td>	<input name="username" type="text" value="<%=username %>"></input>	<font color="#FF0000">*</font>		</td>
    			</tr>
    			<tr>
    			<td class="success">用户密码</td>
    				<td>	<input name="password" type="password" value="<%=password %>"/><h6><font color="#FF0000">若无需修改，请勿动</font></h6>		</td>
    			</tr>
    			<tr>
    				<td class="success">所属部门</td>
    				<td>
    					<select name="company">
							<%
							while(it.hasNext()){
							Unit unit=(Unit)it.next();			
						%>
							<option value="<%=unit.getUnitid() %>" <%
							//System.out.println(company);
							if(unit.getUnitid()==Integer.parseInt(company)){%>selected="selected"<%} %> ><%=unit.getUnitname() %></option>
						<%} %>
						</select>		
    				</td>
    			</tr>
    			<tr>
    				<td class="success">邮件地址</td>
    				<td>	<input name="email" type="text" value="<%=email %>"><font color="#FF0000">*</font>			</td>
    			</tr>
    			<tr>
    				<td class="success">用户类型</td>
    				<td>
    					<select>
							<option>普通用户</option>
						</select>		
    				</td>
    			</tr>
    			
    		</table>
    		<button style="button;float:right;margin-right:30px" class="btn btn-primary" onclick="submit">提交</button>
    		</form>
    	
    </div>
  </body>
</html>
